# Trick Room by Xdan
# 
#==============================================================================
# What is "Trick Room"?
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# If you've never played Pokemon, Trick Room is an attack that chages the rules
# of the battle for a few turns. It inverts the attack order, meaning that 
# slower battlers attack first while faster attackers now will be the last.
# 
#==============================================================================
# Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below Materials but above Main. Remember to save.
#
# Find "if $game_troop.members.any? {|mem| mem.state?(2)}" (it's right below)
# and change "2" to the id of the trick room state. Then make a skill that 
# inflicts the state to the whole enemy team. As long as one enemy has the
# state, the effect of Trick Room will be active.
# 
#==============================================================================
class Game_Action
  def speed
   if $game_troop.members.any? {|mem| mem.state?(2)} #Change "2" to the id of the trick room state
      speed = 9999
      speed -= subject.agi
      speed -= item.speed if item
      speed -= subject.atk_speed if attack?
      speed
    else
      speed = subject.agi
      speed += item.speed if item
      speed += subject.atk_speed if attack?
      speed
    end
  end 
end